home *** CD-ROM | disk | FTP | other *** search
/ Ray Dream Studio / Ray Dream Studio (CDRAYD1) (Ray Dream) (1995).iso / DREAMSDK.WIN / INCLUDE / EVDLLRT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-06  |  3.1 KB  |  156 lines  |  [TEXT/mdos]

  1. /* $Id: EVDLLRT.H 1.12 1995/10/05 20:02:11 JOHN Exp $ */
  2.  
  3. #ifndef __EVDLLRT__
  4. #define __EVDLLRT__
  5.  
  6. #ifndef _WIN31
  7. #define __cdecl 
  8. #endif
  9.  
  10. #ifdef _WIN16
  11. typedef int jmp_buf[9];
  12. #define setjmp RDSetJump
  13. #define longjmp RDLongJump
  14. #endif
  15.  
  16. #ifdef _WIN32
  17. typedef int jmp_buf[16];
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21.     int __cdecl RDSetJump(jmp_buf);
  22.     void  __cdecl RDLongJump(jmp_buf, int);
  23. #ifdef __cplusplus
  24.     }
  25. #endif
  26. #define setjmp RDSetJump
  27. #define longjmp RDLongJump
  28. #endif
  29.  
  30. #ifdef _MAC
  31. #ifdef qPowerPC
  32. typedef long jmp_buf[64];
  33. extern "C" int PPCSetJmp(jmp_buf);
  34. extern "C" void PPCLongJmp(jmp_buf, int);
  35. #define setjmp PPCSetJmp
  36. #define longjmp PPCLongJmp
  37. #else
  38. #include <SetJmp.h>
  39. #endif
  40. #endif
  41.  
  42.  
  43. #ifndef qRFrame
  44. typedef struct {
  45.     short fResFile;
  46.     Handle fTopMapHandle;
  47.     } RDDRMap;
  48. #else
  49. typedef long RDDRMap;
  50. #endif
  51.  
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55.  
  56. void FailNIL(void* apointer);
  57. void FailOSErr(short err);
  58.  
  59. extern void RDDLLMain(void);
  60.  
  61. #ifdef qPowerPC
  62. void RDDLLInit(void);
  63. #endif
  64. short __cdecl RDDLLExport(void (*f)(void), char* name, long appvars);
  65.  
  66. void RDDLLSetupResource(RDDRMap* oldMap);
  67. void RDDLLRestoreResource(RDDRMap* oldMap);
  68.  
  69. long RDDLLSetupA5(void);
  70. void RDDLLRestoreA5(long oldA5);
  71.  
  72. long __cdecl RDDLLTickCount(void);
  73. long __cdecl RDDLLStackSpace(void);
  74.  
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78.  
  79. #if defined(_WIN31)
  80. #define RDEXPORTPROC(f) RDDLLExport((void(*)(void))f, #f, 0);
  81. #define RDEXPORTMEMBER(f,n) RDDLLExport((void(*)(void))f, n, 0);
  82. #elif defined(__MWERKS__)
  83. #define RDEXPORTPROC(f) RDDLLExport((void(*)(void))f, #f, *(long*)0x316);
  84. #define RDEXPORTMEMBER(f,n) RDDLLExport((void(*)(void))f, n, *(long*)0x316);
  85. #else
  86. #define RDEXPORTPROC(f) RDDLLExport((void(*)(void))&f, #f, *(long*)0x316);
  87. #define RDEXPORTMEMBER(f,n) RDDLLExport((void(*)(void))&f, n, *(long*)0x316);
  88. #endif
  89.  
  90. #ifdef __cplusplus
  91.  
  92. #define VOLATILE(a) ((void)&a)
  93.  
  94. class FailInfo {
  95. public:
  96.     jmp_buf savedState;
  97.     short error;
  98.     long message;
  99.     FailInfo* nextInfo;
  100. public:
  101.     FailInfo();
  102.     inline void ReSignal();
  103.     inline void Success();
  104.     inline void Reset();
  105.     };
  106. typedef FailInfo* FailInfoPtr;
  107.  
  108. extern "C" {
  109. void __cdecl Failure(short error, long message);
  110. FailInfoPtr* __cdecl GetGTopHandler(void);
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. // FailInfo inline method definitions
  115. //----------------------------------------------------------------------------------------
  116.  
  117. #ifdef qPowerPC
  118.     extern "C" int PPCSetJmp(jmp_buf env);
  119. #define TRY(f)    \
  120.     f.nextInfo = *GetGTopHandler(),                    \
  121.     *GetGTopHandler() = &f,                            \
  122.     (PPCSetJmp(f.savedState)==0)
  123. #else
  124. #define TRY(f)    \
  125.     f.nextInfo = *GetGTopHandler(),                    \
  126.     *GetGTopHandler() = &f,                            \
  127.     (setjmp(f.savedState)==0)
  128. #endif
  129.  
  130. inline void FailInfo::Reset() {
  131.     error = 0;
  132.     message = 0;
  133.     nextInfo = 0;
  134.     }
  135.  
  136. #if 0
  137. inline Boolean FailInfo::Try() {
  138.     return ::Try(*this);
  139.     }
  140. #endif
  141.  
  142. inline FailInfo::FailInfo() {
  143.     }
  144.  
  145. inline void FailInfo::ReSignal() {
  146.     ::Failure(error, message);
  147.     }
  148.  
  149. inline void FailInfo::Success() {
  150.     *GetGTopHandler() = nextInfo;
  151.     }
  152.     
  153. #endif
  154.  
  155. #endif
  156.